﻿Imports TerrariaVB.Core.Scenes
Imports TerrariaVB.Core.Hud
Imports TerrariaVB.Core.Base
Imports SharpDX.Direct2D1

Public Class MenuScene
    Inherits GameScene

    Public Sub New()
        MyBase.New()
        Name = "Menu"
    End Sub

    Public Overrides Sub Load(e As Core.Base.GameCoreEventArgs)
        MyBase.Load(e)

        Dim hud As New HudLayer()
        Dim startButton As New MenuButton()
        hud.Labels.Add(startButton)
        Me.HudLayer.Add(hud)
    End Sub

    Public Overrides Sub Draw(e As Core.Base.DrawEventArgs)
        MyBase.Draw(e)
    End Sub

    Public Overrides Sub Update(e As Core.Base.GameCoreEventArgs)
        MyBase.Update(e)
    End Sub

End Class

Public Class MenuButton
    Inherits HudLabel

    Private _alphaDelta As Single = 1.0
    Private _alphaStep As Single = 0.001

    Public Sub New()
        MyBase.New()
    End Sub

    Public Overrides Sub Load(e As Core.Base.GameCoreEventArgs)
        MyBase.Load(e)
        Me.Text = "Start"
        Me.FontSize = 48
        Me.BackColor = SharpDX.Color.DarkOrange
        Me.TextColor = SharpDX.Color.DeepSkyBlue
    End Sub

    Public Overrides Sub Update(e As GameCoreEventArgs)
        MyBase.Update(e)
        _alphaDelta += _alphaStep
        If (_alphaDelta >= 1) Then
            _alphaStep = -0.1
        ElseIf (_alphaDelta <= 0.5) Then
            _alphaStep = 0.1

        End If
    End Sub

    Public Overrides Sub Draw(e As DrawEventArgs)

        MyBase.Draw(e)

        Dim brsh As New SolidColorBrush(e.Target, SharpDX.Color.DarkGray)
        brsh.Opacity = _alphaDelta
        e.Target.FillRectangle(Me.GetRectangleCollider(), brsh)
        brsh.Dispose()
    End Sub

End Class

